package info.techgeek.labs.patterns.abstractFactoryPattern;

import java.rmi.*;
import java.rmi.server.*;

public class AWTWidgetFactory extends UnicastRemoteObject
			implements WidgetFactory {
	public AWTWidgetFactory() throws RemoteException{
		super();
		try {
			Naming.rebind("rmi:///WidgetFactory",this);
			System.out.println("Server ready");
		} catch(Exception e){
			System.err.println("Failure setting up WidgetFactory: "
				+ e.getMessage());
		}
	}

	public static void main(String[] args){
		try {
			new AWTWidgetFactory();
		} catch(Exception e){
			System.err.println("Failure creating WidgetFactory: "
				+ e.getMessage());
		}
	}

	//Remote methods
	public Window createWindow(){
		System.out.println("createWindow : Server is doing what the master desires");
		return new AWTWindow();
	}

	public ScrollBar createScrollBar(){
	   System.out.println("createScollBar: Server is doing what the master desires");
		return new AWTScrollBar();
	}
}
